package com.alili_tv.system.service.impl;

import com.alili_tv.system.entity.Message;
import com.alili_tv.system.mapper.CommentMapper;
import com.alili_tv.system.mapper.LikesMapper;
import com.alili_tv.system.service.MessageService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {

    @Resource
    private CommentMapper commentMapper;

    @Resource
    private LikesMapper likesMapper;

    @Override
    public boolean hasNewComments(long userId) {
        // 是否有人回复了我的评论 || 回复了我的视频
        return commentMapper.hasNewToComment(userId) || commentMapper.hasNewToVideo(userId);
    }

    @Override
    public List<Message> getComment(long userId, int pageIndex, int pageSize) {
        return commentMapper.getNew(userId, pageIndex, pageSize);
    }

    @Override
    public boolean hasNewLikes(long userId) {
        return likesMapper.hasNew(userId);
    }

    @Override
    public List<Message> getNewLikes(long userId, int pageIndex, int pageSize) {
        return likesMapper.getNew(userId, pageIndex, pageSize);
    }

    @Override
    public boolean hasNew(Long userId) {
        // 是否有新回复 || 是否有新点赞
        return this.hasNewComments(userId)
                || this.hasNewLikes(userId);
    }

}
